Skip to content

Conversation

@jacob-ebey
Copy link
Contributor

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Jan 8, 2026

🦋 Changeset detected

Latest commit: 7a26be0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
preact-render-to-string Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jacob-ebey
Copy link
Contributor Author

This doesn't work quite the way I had thought. This won't work but was a fun learning experience.

@jacob-ebey jacob-ebey closed this Jan 8, 2026
@jacob-ebey
Copy link
Contributor Author

jacob-ebey commented Jan 9, 2026

This doesn't work with Suspense semantics, but it did lead to a potential new primitive (Shadow) where it's non-template children render in the order they land allowing OOO streaming semantics within a single view with ZERO JS. Deterministic UI order can be achieved with slot names even on <Component slot="target">.

function Wrapper({ children }: { children?: JSX.Children }) {
  return (
    <Shadow ext="section">
      <Shadow.Template>
        <p>before</p>
        <slot>loading</slot>
        <p>after</p>
      </Shadow.Template>
      {children}
    </Shadow>
  );
}

async function Component({
  children,
  delay,
}: {
  children?: JSX.Children;
  delay: number;
}) {
  await new Promise((r) => setTimeout(r, delay * 500));
  return <p>resolved {children}</p>;
}
<html>
  <head></head>
  <body>
    <h1>Hello, World!</h1>
    <Wrapper>
      <Component delay={3}>1</Component>
      <Component delay={4}>2</Component>
      <Wrapper>
        <Component delay={2}>1.1</Component>
        <Component delay={1}>2.1</Component>
      </Wrapper>
    </Wrapper>
  </body>
</html>

HTML lands in chunks denoted below by <!--/chunk-->

<html>
    <head></head>
    <body>
        <h1>Hello, World!</h1>
        <section>
            <template shadowrootmode="open">
                <p>before</p>
                <slot>loading</slot>
                <p>after</p>
            </template>
            
            <!--/chunk-->
            
            <section>
                <template shadowrootmode="open">
                    <p>before</p>
                    <slot>loading</slot>
                    <p>after</p>
                </template>
                <p>resolved 2.1</p>
                
                <!--/chunk-->
                
                <p>resolved 1.1</p>
            </section>

            <!--/chunk-->
            
            <p>resolved 1</p>
            
            <!--/chunk-->
            
            <p>resolved 2</p>
        </section>
    </body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant